Repository navigation
Container: a reset keeps the sort pending for the children it keeps - #1836
Merged
Merged
Conversation
Adding a child queues a sort for the next tick. Container#reset cancelled that sort, then removed every child that is not persistent, so the persistent ones it kept stayed in the order they were added, their depth ignored, until something else sorted the container. A screen that adds its persistent objects and loads a level straight away got exactly that, since level.load resets the world: a background added first was drawn over everything. reset() now sorts again when a sort was pending and children remain. destroy() does not: it goes through clearChildren alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA2BZwXkRJLpNxCXBNt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4xBNBw7cEZzG1bUru
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adding a child to a container appends it and queues a sort for the next tick.
Container#reset()cancelled that sort (inclearChildren), then removed every child that is not persistent. The persistent children it kept therefore stayed in the order they were added, their depth ignored, until something else sorted the container.The usual way to get there: a screen adds its persistent objects and loads a level straight away.
level.loadresets the world, so the screen's own objects were never sorted:It showed up in the Starsweep example as a screen with nothing but the background on it. The example works around it with a
world.sort()after each load.Fix
reset()notes whether a sort was pending and, if any children remain after clearing, sorts again (the same deferredsort()thataddChildqueues).destroy()is untouched. It callsclearChildrendirectly, so nothing is queued against a destroyed container, which is the problem theclearChildrensplit was made to avoid.Also:
Fixedentry.Type of change
Checklist
pnpm lintpasses): Biome andtscclean, no new ESLint warningspnpm testpasses): full engine suite, 379 files / 9624 tests passtests/container-reset-sort.spec.js. Thereset()case and thelevel.loadcase fail without the fix (skyon top) and pass with it. Three more pin that no sort is queued when none was pending, when no children remain, or ondestroy().pnpm build): left to CIRelated issues
None.
Generated by Claude Code